package com.lwj.liwanjia.presenter;

import com.lwj.liwanjia.bean.EditAddressBean;
import com.lwj.liwanjia.impl.EditAddressView;
import com.lwj.liwanjia.model.EditAddressModel;

import rx.Subscriber;

/**
 * Created by Administrator on 2017/10/11.
 */

public class EditAddressPresenter {
    private EditAddressModel editAddressModel;
    private EditAddressView editAddressView;

    public EditAddressPresenter(EditAddressView editAddressView) {
        this.editAddressView = editAddressView;
        editAddressModel = new EditAddressModel();
    }

    public void editAddress(String token, String consigneeId) {
        if (editAddressView != null) {
            editAddressModel.editAddress(token, consigneeId, new Subscriber<EditAddressBean>() {
                @Override
                public void onCompleted() {

                }

                @Override
                public void onError(Throwable e) {
                    editAddressView.showError((Exception) e);
                }

                @Override
                public void onNext(EditAddressBean editAddressBean) {
                    editAddressView.editAddress(editAddressBean);
                }
            });
        }
    }
}
